package com.usian.skill.mq;

import com.alibaba.fastjson.JSON;
import com.usian.skill.pojo.SkillMessage;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ClassName: MQSender
 * Author:   WGG
 * Date:    2022-12-2022/12/13-19:58
 * Version: 1.0
 * Description:
 */
@Component
@Slf4j
public class MQSender {
    @Autowired
    AmqpTemplate amqpTemplate;

    public void sendMiaoShaMessage(Object mm){
        //将mm转换成json数据
        String json = JSON.toJSONString(mm);
        log.info("send message: "+json);
        log.info("send message: {}",json);
        //发送消息
        amqpTemplate.convertAndSend(MQConfig.QUEUE,json);
    }
   public void sendMiaoShaMessage(SkillMessage smg){
        //将mm转换成json数据
        String json = JSON.toJSONString(smg);
        log.info("send message: "+json);
        log.info("send message: {}",json);
        //发送消息
        amqpTemplate.convertAndSend(MQConfig.SKILLQUEUE,json);
    }
}
